<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('诊疗单列表')"/>
</head>
<body class="gray-bg">


<div class="container-div">
    <div class="row">

        <div class="col-sm-12 search-collapse">
            <div class="btn-group " style="margin: 0px auto;display: table;" role="group">
                <button type="button" id="cowZhenLiao" class="top-link btn btn-sm btn-white">牛舍</button>
                <button type="button" id="chickenZhenLiao" class="top-link btn-sm btn-primary" >鸡舍</button>
            </div>
        </div>

        <div class="btn-group-sm" id="toolbar2" role="group">
            <h3 class="line">诊疗受理：</h3>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table-mianyi-logs-status1" data-mobile-responsive="true"></table>
        </div>

        <div class="btn-group-sm" id="toolbar1" role="group">
            <a class="btn btn-primary " onclick="openOrder()">
                <i class="fa fa-table"></i> 诊疗单
            </a>

            <a class="btn btn-warning" onclick="confirmTable();" shiro:hasPermission="system:ncZhenliaoLogs:confirm">
                <i class="fa fa-send"></i> 单据确认
            </a>
            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:ncZhenliaoLogs:add">
                <i class="fa fa-plus"></i> 新增
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table-mianyi-logs-status2" data-mobile-responsive="true"></table>
        </div>
        <div class="bottom-btns"></div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:ncZhenliaoLogs:edit')}]];
    var removeFlag = [[${@permission.hasPermi('system:ncZhenliaoLogs:remove')}]];
    var prefix = ctx + "system/ncZhenliaoLogs/chicken";


    $(function () {
        var optionsStatus1 = {
            id: "bootstrap-table-mianyi-logs-status1",
            url: prefix + "/list/2/1",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "诊疗单",
            showExport: true,
            striped: true,
            showSearch: true,
            showRefresh: true,
            showColumns: true,
            showToggle: true,
            toolbar: 'toolbar2',
            columns: [
                {
                    title: '序号',
                    formatter: function (value, row, index) {
                        return $.table.serialNumber(index);
                    }
                },
                {
                    field: 'zlId',
                    title: '诊疗单号',
                    visible: false
                },
                {
                    field: 'roomNum',
                    title: '鸡舍号',
                    sortable: true
                },
                {
                    field: 'illMuns',
                    title: '发病次数',
                    sortable: true
                },
                {
                    field: 'symptom',
                    title: '症状',
                    sortable: true
                },
                {
                    field: 'reportUser ',
                    title: '推送人',
                    sortable: true
                },
                {
                    field: 'remark',
                    title: ' 备注',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-primary btn-xs" href="javascript:void(0)" onclick="confirmCheck(\'' + row.zlId + '\')"><i class="fa fa-send"></i>确认</a>');
                        return actions.join('');
                    }
                }]
        };

        var optionsStatus2 = {
            id: "bootstrap-table-mianyi-logs-status2",
            url: prefix + "/listConfirm/2/3",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "诊疗单",
            showExport: true,
            striped: true,
            showSearch: true,
            showRefresh: true,
            showColumns: true,
            showToggle: true,
            toolbar:'toolbar1',
            columns: [{
                checkbox: true
            },{
                title: '序号',
                formatter: function (value, row, index) {
                    return $.table.serialNumber(index);
                }
            },
                {
                    field: 'zlId',
                    title: '序号',
                    visible: false
                },
                {
                    field: 'roomNum',
                    title: '鸡舍号',
                    sortable: true
                },
                {
                    field: 'illMuns',
                    title: '发病次数',
                    sortable: true
                },
                {
                    field: 'symptom',
                    title: '症状',
                    sortable: true
                },
                {
                    field: 'reportUserName',
                    title: '推送人'
                },
                {
                    field: 'zlUserName',
                    title: '诊疗人员'
                }, {
                    field: 'drugName',
                    title: '药品名称',
                    sortable: true
                },

                {
                    field: 'zlResult',
                    title: '诊疗结果',
                    sortable: true
                },
                {
                    field: 'zlTime',
                    title: '诊疗时间',
                    sortable: true
                },

                {
                    field: 'remark',
                    title: ' 备注',
                    sortable: true,
                    formatter: function (value, row, index) {
                        return $.table.tooltip(value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.zlId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.zlId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };

        $.table.init(optionsStatus1);
        $.table.init(optionsStatus2);


        var btns2 = [
            {
                name: '免疫管理',
                url: ctx + 'system/ncMianyiLogs/chicken',
                id: 'cow_minayi-work'
            },
            {
                name: '巡视管理',
                url: ctx + 'system/ncXunshiLogs/chicken',
                id: 'cow_xunshi-work'
            },
            {
                name: '工作记录',
                url: ctx + 'system/ncNormalWorks?workType=9',
                id: 'normal-work'
            },
            {
                name: '兽药管理',
                url: ctx + 'system/ncDrugs',
                id: 'drugs-work'
            }
        ];
        addBtns(btns2);


        $("#cowZhenLiao").click(function () {
            window.location.href = ctx + 'system/ncZhenliaoLogs/cow';
            return;
        });

        $("#chickenZhenLiao").click(function () {
            window.location.href = ctx + 'system/ncZhenliaoLogs/chicken';
            return;

        });


    });




    //新增诊疗单
    function addZhenLiaoLogs(name, url) {
        $.modal.openTab(name, url);
    }



    /*打开鸡舍诊疗记录单*/
    function openOrder() {
        var url = ctx + 'system/ncOrder?orderType=17';
        $.modal.openTab("鸡舍诊疗记录单", url);
    }



    /*确认检测 单条*/
    function confirmCheck(id) {
        var url = prefix + "/confirmCheck/" + id;
        $.modal.open("诊疗单确认", url);
    }


    /*表单确认*/
    function confirmTable() {
        var confirmTable = prefix + "/confirmTable";
        var data = $('#bootstrap-table-mianyi-logs-status2').bootstrapTable('getData');
        if (data && data.length > 0) {
            $.modal.confirm("确认生成鸡舍诊疗单吗？", function () {
                var ids = [];
                $(data).each(function (i, e) {
                    if (this[0]) {
                        ids.push(e.zlId);
                    }
                });
                var ids_str = ids.join(",");
                myPost(confirmTable, {
                        ids: ids_str,
                        orderType : 17
                    },
                    function (data) {

                        if (0 == data.code) {
                            layer.msg("提交成功")
                        } else {
                            layer.msg(data.msg);
                        }
                        reload()
                    }, function (e) {
                        layer.msg("确认失败!");
                        reload()
                    })

            })
        } else {
            layer.msg("未发现数据!")
        }

    }
    function askZhenLiao() {
        $.modal.open("添加", "/system/ncZhenliaoLogs/chicken/askZhenLiao");
    }


    //刷新页面
    function reload() {
        parent.$('bootstrap-table-mianyi-logs-status2').bootstrapTable('refresh', {
            silent: true
        });
        parent.$('bootstrap-table-mianyi-logs-status1').bootstrapTable('refresh', {
            silent: true
        });
    }
    setTitle("兽医管理-鸡舍",false)
</script>
</body>
</html>